{extend name="base"/}
{block name="title"}
    商家入驻
{/block}
{block name="css"}
<style>
    .time{
        width: 36%; 
    }    
</style>
<link rel="stylesheet" href="__MOBILE__/css/zhang.css">
{/block}
{block name="content"}
<div class="head">
    <div class="head_left"><a href="javascript:history.go(-1)"><img src="__MOBILE__/images/true.png" alt=""></a></div>
    <div class="head_con">商家入驻</div>
    <div class="head_right"></div>
</div>

<ul class="in">
    <!-- <li>
       <a href="{:url('/langjinmobile/card/map')}"><img src="__MOBILE__/images/dizhi.png" alt=""> <input type="text" placeholder="详细地址" readonly="readonly"></a>
    </li> -->
    <li>
        <img src="__MOBILE__/images/shangjia.png" alt=""> <input type="text" name="name" value="{$business_info['name']}" placeholder="商家名称">
    </li>
    <li>
        <img src="__MOBILE__/images/lianxiren.png" alt=""> <input type="text" name="contact" value="{$business_info['contact']}" placeholder="联系人">
    </li>
    <li>
        <img src="__MOBILE__/images/dianhua.png" alt=""> <input type="number" name="mobile" value="{$business_info['mobile']}" placeholder="联系电话">
    </li>
    <li>
        <img src="__MOBILE__/images/shijian.png" alt=""> 
        <input style="width: 36%;" type="text" name="start_time" value="{$business_info['start_time']}" placeholder="营业开始时间">
        至<input style="width: 36%;" type="text" name="end_time" value="{$business_info['end_time']}" placeholder="营业结束时间">
    </li>
    <li>
        <img src="__MOBILE__/images/jieshao.png" alt="">　商家介绍 
    </li>
</ul>

    <div class="liuyan"><textarea name="introduce" value="" id="Leave_age" cols="40" rows="6" placeholder="请在这里填写介绍:">{$business_info['introduce']}</textarea></div>
    <div class="picture"><img src="__MOBILE__/images/shangjiatupian.png" alt=""><span>商家图片</span></div> 
<form id="img">
    <div class="shangchuan">
        <div class="screen">
            <input type="file" name="shop_img" id="shots" onchange="scoos()">
            {if $business_info['shop_img']}
            <img src="{$business_info['shop_img']}" alt="" id="preview">
            {else/}
            <img src="__MOBILE__/images/huin.png" alt="" id="preview">
            {/if}
        </div>
        <div class="screen">
            <input type="file" name="business_img" id="shotss" onchange="scooss()">
            {if $business_info['business_img']}
            <img src="{$business_info['business_img']}" alt="" id="preview">
            {else/}
            <img src="__MOBILE__/images/zhiin.png" alt="" id="previews">
            {/if}
        </div>
    </div>   
</form>
{if $business_info}
    <p class="tishi">审核状态：{$business_info.status}</p>
<p class="tishi">已通过审核商户,如重新提交资料,则需要新审核商户信息.审核期间商户功能将无法使用,请谨慎操作.</p>
    {else/}
    <p class="tishi">已通过审核商户,如重新提交资料,则需要新审核商户信息.审核期间商户功能将无法使用,请谨慎操作.</p>
    {/if}
<button class="applys">提交申请</button>
{/block}
{block name="js"}
<script type="text/javascript" src="__MOBILE__/layui/layui.js"></script>
<script type="text/javascript">
function scoos(){
    var f = document.getElementById('shots').files[0];
    src = window.URL.createObjectURL(f);
    document.getElementById('preview').src = src;
}
function scooss(){
    var f = document.getElementById('shotss').files[0];
    src = window.URL.createObjectURL(f);
    document.getElementById('previews').src = src;
}

$('.applys').click(function (){
    var name = $('input[name="name"]').val();
    var contact = $('input[name="contact"]').val();
    var mobile = $('input[name="mobile"]').val();
    var start_time = $('input[name="start_time"]').val();
    var end_time = $('input[name="end_time"]').val();
    var introduce = $('textarea[name="introduce"]').val();

    var form  = new FormData();
    form.append('name', name);
    form.append('contact', contact);
    form.append('mobile', mobile);
    form.append('start_time', start_time);
    form.append('end_time', end_time);
    form.append('introduce', introduce);
    if($("#shots")[0].files[0])
        form.append('shop_img', $("#shots")[0].files[0]);
    if($("#shotss")[0].files[0])
    form.append('business_img', $("#shotss")[0].files[0]);

    layer.confirm('申请审核中,确认重新提交?',{
        title: '商家入驻',
        btn: ['好的', '不好'],
        icon : 3,
    },function(index){
        layer.close(index);
        $.ajax({
            url: 'sendApply',
            type: 'POST',
            data: form,
            processData: false,
            contentType: false,
            success:function (res){
                if(res.code == 1){
                    setTimeout(window.location.href=res.url, 2000);
                    msg_alert(res.msg);
                }else{
                    msg_alert(res.msg);
                }
            },
            error: function(){
                msg_alert('接口请求失败');
            }
        })
    })

})
</script>
{/block}